﻿CREATE TABLE [dbo].[PropertyInstances] (
    [PropertyInstanceId]   BIGINT IDENTITY (1, 1) NOT NULL,
    [PrototypedObjectId]   BIGINT NOT NULL,
    [PrototypedObjectType] BIGINT NOT NULL,
    [DataTypeId]           BIGINT NOT NULL,
    [PropertyMappingId]    BIGINT NOT NULL,
    [PropertyInstanceValueId] BIGINT NOT NULL, 
    CONSTRAINT [PK_PropertyInstances] PRIMARY KEY CLUSTERED ([PropertyInstanceId] ASC),
    CONSTRAINT [FK_PropertyInstances_DataTypes] FOREIGN KEY ([DataTypeId]) REFERENCES [dbo].[DataTypes] ([DataTypeId]),
    CONSTRAINT [FK_PropertyInstances_ObjectTypes] FOREIGN KEY ([PrototypedObjectType]) REFERENCES [dbo].[ObjectTypes] ([ObjectTypeId]),
    CONSTRAINT [FK_PropertyInstances_PropertyMappings] FOREIGN KEY ([PropertyMappingId]) REFERENCES [dbo].[PropertyMappings] ([PropertyMappingId])
);

